# 抖码算法，让算法学习变得简单有趣
# 作者：老汤
from typing import List


class Employee:
    def __init__(self, id: int, importance: int, subIds: List[int]):
        self.id = id
        self.importance = importance
        self.subIds = subIds


emp_map = {}


def getImportance(self, employees: List[Employee], id: int) -> int:
    self.emp_map = {emp.id: emp for emp in employees}

    return self.bfs(id)


def dfs(self, id: int) -> int:
    emp, total = self.emp_map[id], 0
    for child in emp.subIds:
        total += self.dfs(child)
    return emp.importance + total